import { path } from "../../config/path";
import request from './request';
// const ApiUrl = [
//   'manage/login', //登录
// ];
// function check_url(url: string) {
//   let idx = ApiUrl.findIndex((item) => item === url);
//   if (idx >= 0) {
//     return true;
//   }
// }
// export function apiRequest(method: string) {
//   if (method === 'GET') {
//     return async function (url: string, body?: any, options?: { [key: string]: any }) {
//       if (check_url(url)) {
//         return request(path + `/${url}`, {
//           method: 'GET',
//           headers: {
//             Authorization: localStorage.loginToken,
//           },
//           params: body,
//           ...(options || {}),
//         });
//       }
//     };
//   }
//   if (method === 'POST') {
//     return async function (url: string, body?: any, options?: { [key: string]: any }) {
//       if (check_url(url)) {
//         return request(path + `/${url}`, {
//           method: 'POST',
//           headers: {
//             Authorization: localStorage.loginToken,
//           },
//           data: body,
//           ...(options || {}),
//         });
//       }
//     };
//   }
// }
/** 登录接口 POST /login */
export async function admin_login(body: any, options?: any) {
  return request(path + '/manage/login', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}
/** 获取当前的用户信息 GET /manage/get_info */
export async function myself(options?: any) {
  return request(path + '/manage/get_info', {
    method: 'GET',
    headers: {
      Authorization: localStorage.loginToken,
    },
    ...(options || {}),
  });
}
/** 获取验证码 POST /common/send_code*/
export async function getCode(body: any, options?: any) {
  return request(path + '/common/send_code', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}
/** 找回密码 POST /manage/find_password */
export async function find_password(body: any, options?: any) {
  return request(path + '/manage/find_password', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}
/** 编辑个人信息 POST /manage/edit_info */
export async function edit_info(body: any, options?: any) {
  return request(path + '/manage/edit_info', {
    method: 'POST',
    headers: {
      Authorization: localStorage.loginToken,
    },
    data: body,
    ...(options || {}),
  });
}
